package com.dq.health.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dq.health.dto.request.notice.QueryNoticeParam;
import com.dq.health.entity.notice.Notice;
import com.dq.health.enums.NoticeStatusEnum;
import com.dq.health.service.IAPINoticeService;
import com.dq.health.utils.data.JsonUtil;
import com.dq.health.utils.view.SimpleView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <>
 *
 * @Author: chenxin
 * @Date: 2021/5/20
 */
@RequestMapping("/visitor")
@RestController
@Api(tags = "游客接口")
public class VisitorController {

    private static final Logger LOGGER = LoggerFactory.getLogger(VisitorController.class);

    @Autowired
    private IAPINoticeService noticeService;

    @PostMapping("/queryNoticeInfoList")
    @ApiOperation("查询公告列表")
    public SimpleView<IPage<Notice>> queryNoticeInfoList(@RequestBody QueryNoticeParam request) {
        LOGGER.info("### visitor queryNoticeInfoList req:{}", JsonUtil.toString(request));
        SimpleView<IPage<Notice>> view = new SimpleView<>();

        request.setNoticeStatus(NoticeStatusEnum.PUSHED.getValue());
        IPage<Notice> page = noticeService.queryPageList(request);
        view.success(page);

        return view;
    }

}
